<?php

namespace app\admin\model;

use think\Model;

class Live extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'k_decoration_case';

    // 将图相对地址片转为网络地址
    public function getOriginalImgAttr($value)
    {
        return "https://huaxiaoujia.oss-cn-beijing.aliyuncs.com/" . $value;
    }

    // 获取直播状态
    public function getLiveStatusAttr($value)
    {
        return config('config')['live_status'][$value];
    }

    // 获取小区名称
    public function getVillageAttr($value)
    {
        return db('village')->find($value)['name'];
    }

    // 获取小区对应户型
    public function getHouseTypeAttr($value)
    {
        return db('housetype')->find($value)['name'];
    }

    public function getTeamsAttr($value)
    {
        $teams = explode(',', $value);
        return model('UserType')->field('user_id,name,type')->where('user_id', 'in', $teams)->limit(3)->select();
    }
}
